feat(share): add --force flag to share delete for orphan cleanup - #40
Merged
Conversation
`arc share delete <id>` previously had no recovery path for entries in ~/.arc/shares.json that had become unusable — either the edit_token was missing locally, or the server returned 404/403/network errors. Both cases left a dead row in the registry with no way to prune it. Add a --force / -f flag that turns delete into a best-effort cleanup: warn instead of erroring when the edit_token is missing (skip server call), warn instead of erroring when the server delete fails, and always remove the local registry entry. Default behavior is unchanged. Also set SilenceUsage on shareDeleteCmd so runtime errors no longer dump the cobra help block — usage should only print for actual usage errors (wrong arg count, bad flag), matching the existing pattern in self.go.
- Wrap long error message to satisfy revive line-length-limit (120) - Discard fmt.Fprintf return values via _, _ = ... and use os.Stderr directly to match the existing pattern in share.go / self.go / docs.go (revive unhandled-error)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--force/-ftoarc share deleteso users can prune dead entries from~/.arc/shares.jsonwhen normal delete can't proceed (missing localedit_token, or the server returns 404/403/network errors).SilenceUsage: trueonshareDeleteCmdso runtime errors no longer dump the cobra help block — matches the existing pattern incmd/arc/self.go.Behavior
--forceis a client-side cleanup flag. The server still requires a valid edit token to actually delete a share —--forcejust lets the user prune their own registry when they can't satisfy that requirement.--force--forceshares.jsonedit_tokendeleteShareDefault behavior is unchanged.
Motivation
Discovered while trying to delete
my3xje4x, a share whose server (localhost:7446) was no longer running — the entry was stuck in the registry with no clean removal path.Test plan
arc share delete <id>against an unreachable server now succeeds with--forceand warns about the network failurearc share listconfirms the orphan is removedarc share delete bogus123(unknown ID) emits a clean one-line error — no usage dumparc share delete <id>(without--force, valid local + reachable server) still works as beforego build ./...,go vet ./cmd/arc/...,go test ./cmd/arc/...all clean